<?php
require_once 'glob.php';
$errmsg='对不起你没有权限进入该页面!';
if($_REQUEST['page']==""||$_REQUEST['page']==null)
{
	$page=1;
}else {
	$page=$_REQUEST['page'];
}

switch ($_REQUEST['action']) {
	/******************************************************************/
	case 'list':
		check_admin_type('super',$errmsg);
		get_list('sn_adminmenu', array(id,name,ower,ordid),'topmenulist','menu_list.htm','fypage',$page,'where upid = 0 order by ordid','?action=list&');

		break;

		/******************************************************************/
	case 'add':
		check_admin_type('super',$errmsg);
		//管理员类型下拉菜单（添加了all这个类型）
		$xueniao->assign('admintype',get_admintype('所有用户','all'));
		//上级菜单下拉
		$xueniao->assign('topmenu',get_upclass('sn_adminmenu','无上级','0'));
		$xueniao->display('menu_info.htm');
		break;
		/******************************************************************/
	case 'insert':
		if($_REQUEST['fm_name']!=="")
		{
			$post=array(
			name=>$_REQUEST['fm_name'],
			link=>$_REQUEST['fm_link'],
			upid=>$_REQUEST['fm_upid'],
			ower=>$_REQUEST['fm_ower'],
			ordid=>$_REQUEST['fm_ordid']
			);
			$res=$db->insert('sn_adminmenu',$post);
			if($res==true){
				sys_msg('菜单添加成功',0);
			}
		}
		break;

		/******************************************************************/
	case 'edit':
		check_admin_type('super',$errmsg);

		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定菜单,无法修改', 0);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}

		//管理员类型下拉菜单（添加了all这个类型）
		$xueniao->assign('admintype',get_admintype('所有用户','all'));
		//上级菜单下拉
		$xueniao->assign('topmenu',get_upclass('sn_adminmenu','无上级','0','and id !='.$fm_id));
		get_info('sn_adminmenu',array(name,link,upid,ordid,ower), 'menuinfo', 'menu_info.htm','id = '.$fm_id);

		break;

		/******************************************************************/

	case 'update':
		check_admin_type('super',$errmsg);
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定菜单,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}

		$post=array(
		id=>$fm_id,
		//要更改的id
		name=>$_REQUEST['fm_name'],
		link=>$_REQUEST['fm_link'],
		upid=>$_REQUEST['fm_upid'],
		ower=>$_REQUEST['fm_ower'],
		ordid=>$_REQUEST['fm_ordid']
		);

		$res=$db->update('sn_adminmenu',$post,id);

		if($res==true){
			sys_msg('菜单信息修改成功！',0);
		}
		break;
	default:
		check_admin_type('super',$errmsg);
		get_list('sn_adminmenu', array(id,name,ower,ordid),'topmenulist','menu_list.htm','fypage',$page,'where upid = 0 order by ordid','?action=list&');
		break;

}


?>